package com.log.controller;

import com.log.request.AddLogRequest;
import com.log.service.LogService;
import com.log.util.JsonData;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @ClassDescription:
 * @Author: zhaoyi
 * @Created: 2024/7/12 10:52
 */
@RequestMapping("/log")
@RestController
@RequiredArgsConstructor
public class logController {

    private final LogService logService;

    @PostMapping("created")
    public JsonData creatLogFile(@RequestBody AddLogRequest request){

        return JsonData.buildSuccess(logService.creatLogFile(request));
    }


    @PostMapping("analysis")
    public JsonData analysisLogFile(@RequestBody AddLogRequest request) {

        return JsonData.buildSuccess(logService.readFileAndSend(request.getCoreSize()));
    }


}
